package source.events.action;

import source.model.*;
import source.model.type.*;
import source.model.technology.*;
import source.view.MainScreen;

public class ChangeCurrentResearch implements Action {
		
        int playerID;

        public ChangeCurrentResearch(int playerID){
                this.playerID=playerID;
        }

        public ActionResult execute(DataHandler dh){
                Player p=dh.getPlayer(playerID);
                Technology tech;
                String[] s = new String[6];
                s[0] = new String("Unit Armor Upgrade");
                s[1] = new String("Unit Defensive Damage Upgrade");
                s[2] = new String("Unit Health Upgrade");
                s[3] = new String("Offensive Unit Offensive Damage Upgrade");
                s[4] = new String("Ranged Unit Range Upgrade");
                s[5] = new String("Unit Speed Upgrade");
                String result = MainScreen.showBuildDialog("Select a research tech", s);

        if(result.equals("Unit Armor Upgrade"))
        {
                tech = new UpgradeUnitArmor();
                p.researchNewTechnology(tech);
        }
        else if(result.equals("Unit Defensive Damage Upgrade"))
        {
                tech = new UpgradeUnitDefensiveDamage();
                p.researchNewTechnology(tech);
        }
        else if(result.equals("Unit Health Upgrade"))
        {
                tech = new UpgradeUnitHealth();
                p.researchNewTechnology(tech);
        }
        else if(result.equals("Offensive Unit Offensive Damage Upgrade"))
        {
                tech = new UpgradeUnitOffensiveDamage();
                p.researchNewTechnology(tech);
        }
        else if(result.equals("Ranged Unit Range Upgrade"))
        {
                tech = new UpgradeUnitRange();
                p.researchNewTechnology(tech);
        }
        else if(result.equals("Unit Speed Upgrade"))
        {
                tech = new UpgradeUnitSpeed();
                p.researchNewTechnology(tech);
        }
		return ActionResult.SUCCESS;
	}
}
